const {BusiError, SysError} = require('../exception/exception');
const qftUnionPayService = require('./QftUnionPayService');
const qftUnionPayNativeService = require('./QftUnionPayNativeService');
const qftWechatQrCodePayService = require('./QftWechatQrCodePayService');
const qftAlipayQrCodePayService = require('./QftAlipayQrCodePayService');
const mdfUnionPayService = require('./MdfUnionPayService');
const mergeUnionPayService = require('./MergeUnionPayService');
const payOrderDao = require('../dao/payOrderDao');
const juHePayService = require('./JuHePayService');

class PayService {
    constructor() {
        this.payMap = {
            "J001": qftUnionPayService,
            "J002": qftWechatQrCodePayService,
            "J003": qftAlipayQrCodePayService,
            "J004": qftUnionPayNativeService,
            "J005": mdfUnionPayService,
            "J006": mergeUnionPayService,
            //add
            "JuHe":juHePayService,
        };
    }

    // 订单状态: 0创建订单 1支付成功 -1订单关闭 -2支付失败
    /**
     *  通过编码获取支付服务
     * @param {String} payCode
     * @returns {Promise<PayService>}
     */
    getService(payCode) {
        return this.payMap[payCode];
    }

    /**
     * 查询支付订单列表
     * @param {String} orderType
     * @returns {Promise<*>}
     */
    async queryOrdersByOrderType(orderType) {
        return await payOrderDao.queryByOrderType(orderType);
    }
}


let payService = new PayService();
module.exports = payService;